home *** CD-ROM | disk | FTP | other *** search
- package java.lang;
-
- import java.io.PrintStream;
- import ms.applet.AppletViewer;
-
- public class ThreadGroup {
- ThreadGroup parent;
- String name;
- int maxPriority;
- boolean destroyed;
- boolean daemon;
- int nthreads;
- Thread[] threads;
- int ngroups;
- ThreadGroup[] groups;
-
- private ThreadGroup() {
- this.name = "system";
- this.maxPriority = 10;
- }
-
- public ThreadGroup(String var1) {
- Thread var2 = Thread.currentThread();
- this(var2.group, var1);
- }
-
- public ThreadGroup(ThreadGroup var1, String var2) {
- if (var1 == null) {
- throw new NullPointerException();
- } else {
- var1.checkAccess();
- this.name = var2;
- this.maxPriority = var1.maxPriority;
- this.daemon = var1.daemon;
- this.parent = var1;
- var1.add(this);
- }
- }
-
- public final String getName() {
- return this.name;
- }
-
- public final ThreadGroup getParent() {
- return this.parent;
- }
-
- public final int getMaxPriority() {
- return this.maxPriority;
- }
-
- public final boolean isDaemon() {
- return this.daemon;
- }
-
- public final void setDaemon(boolean var1) {
- this.checkAccess();
- this.daemon = var1;
- }
-
- public final synchronized void setMaxPriority(int var1) {
- this.checkAccess();
- if (var1 < 1) {
- this.maxPriority = 1;
- } else if (var1 < this.maxPriority) {
- this.maxPriority = var1;
- }
-
- for(int var2 = 0; var2 < this.ngroups; ++var2) {
- this.groups[var2].setMaxPriority(var1);
- }
-
- }
-
- public final boolean parentOf(ThreadGroup var1) {
- while(var1 != null) {
- if (var1 == this) {
- return true;
- }
-
- var1 = var1.parent;
- }
-
- return false;
- }
-
- public final void checkAccess() {
- SecurityManager var1 = System.security;
- if (var1 != null) {
- var1.checkAccess(this);
- }
-
- }
-
- public synchronized int activeCount() {
- if (this.destroyed) {
- return 0;
- } else {
- int var1 = this.nthreads;
-
- for(int var2 = 0; var2 < this.ngroups; ++var2) {
- var1 += this.groups[var2].activeCount();
- }
-
- return var1;
- }
- }
-
- public int enumerate(Thread[] var1) {
- return this.enumerate((Thread[])var1, 0, true);
- }
-
- public int enumerate(Thread[] var1, boolean var2) {
- return this.enumerate((Thread[])var1, 0, var2);
- }
-
- private synchronized int enumerate(Thread[] var1, int var2, boolean var3) {
- if (this.destroyed) {
- return 0;
- } else {
- int var4 = this.nthreads;
- if (var4 > var1.length - var2) {
- var4 = var1.length - var2;
- }
-
- if (var4 > 0) {
- System.arraycopy(this.threads, 0, var1, var2, var4);
- var2 += var4;
- }
-
- if (var3) {
- for(int var5 = 0; var5 < this.ngroups; ++var5) {
- var2 = this.groups[var5].enumerate(var1, var2, true);
- }
- }
-
- return var2;
- }
- }
-
- public synchronized int activeGroupCount() {
- if (this.destroyed) {
- return 0;
- } else {
- int var1 = this.ngroups;
-
- for(int var2 = 0; var2 < this.ngroups; ++var2) {
- var1 += this.groups[var2].activeGroupCount();
- }
-
- return var1;
- }
- }
-
- public int enumerate(ThreadGroup[] var1) {
- return this.enumerate((ThreadGroup[])var1, 0, true);
- }
-
- public int enumerate(ThreadGroup[] var1, boolean var2) {
- return this.enumerate((ThreadGroup[])var1, 0, var2);
- }
-
- private synchronized int enumerate(ThreadGroup[] var1, int var2, boolean var3) {
- if (this.destroyed) {
- return 0;
- } else {
- int var4 = this.ngroups;
- if (var4 > var1.length - var2) {
- var4 = var1.length - var2;
- }
-
- if (var4 > 0) {
- System.arraycopy(this.groups, 0, var1, var2, var4);
- var2 += var4;
- }
-
- if (var3) {
- for(int var5 = 0; var5 < this.ngroups; ++var5) {
- var2 = this.groups[var5].enumerate(var1, var2, true);
- }
- }
-
- return var2;
- }
- }
-
- public final synchronized void stop() {
- this.checkAccess();
-
- for(int var1 = 0; var1 < this.ngroups; ++var1) {
- this.groups[var1].stop();
- }
-
- for(int var2 = 0; var2 < this.nthreads; ++var2) {
- Thread var3 = this.threads[var2];
- var3.stop(new ThreadDeath());
- }
-
- }
-
- public final synchronized void suspend() {
- this.checkAccess();
-
- for(int var1 = 0; var1 < this.ngroups; ++var1) {
- this.groups[var1].suspend();
- }
-
- for(int var2 = 0; var2 < this.nthreads; ++var2) {
- Thread var3 = this.threads[var2];
- var3.checkAccess();
- var3.suspend0();
- }
-
- }
-
- public final synchronized void resume() {
- this.checkAccess();
-
- for(int var1 = 0; var1 < this.ngroups; ++var1) {
- this.groups[var1].resume();
- }
-
- for(int var2 = 0; var2 < this.nthreads; ++var2) {
- Thread var3 = this.threads[var2];
- var3.checkAccess();
- var3.resume0();
- }
-
- }
-
- public final synchronized void destroy() {
- boolean var1 = false;
- AppletViewer var2 = AppletViewer.getAppletViewer();
- if (var2 != null && var2.closing()) {
- var1 = true;
- }
-
- if (!var1) {
- this.checkAccess();
- }
-
- if (!this.destroyed && (var1 || this.nthreads <= 0)) {
- while(this.ngroups > 0) {
- this.groups[0].destroy();
- }
-
- if (this.parent != null) {
- this.destroyed = true;
- this.groups = null;
- this.threads = null;
- this.parent.remove(this);
- }
-
- } else {
- throw new IllegalThreadStateException();
- }
- }
-
- private final synchronized void add(ThreadGroup var1) {
- if (this.destroyed) {
- throw new IllegalThreadStateException();
- } else {
- if (this.groups == null) {
- this.groups = new ThreadGroup[4];
- } else if (this.ngroups == this.groups.length) {
- ThreadGroup[] var2 = new ThreadGroup[this.ngroups * 2];
- System.arraycopy(this.groups, 0, var2, 0, this.ngroups);
- this.groups = var2;
- }
-
- this.groups[this.ngroups] = var1;
- ++this.ngroups;
- }
- }
-
- private synchronized void remove(ThreadGroup var1) {
- if (!this.destroyed) {
- for(int var2 = 0; var2 < this.ngroups; ++var2) {
- if (this.groups[var2] == var1) {
- System.arraycopy(this.groups, var2 + 1, this.groups, var2, --this.ngroups - var2);
- this.groups[this.ngroups] = null;
- break;
- }
- }
-
- if (this.nthreads == 0) {
- this.notifyAll();
- }
-
- if (this.daemon && this.nthreads == 0 && this.ngroups == 0) {
- this.destroy();
- }
-
- }
- }
-
- synchronized void add(Thread var1) {
- if (this.destroyed) {
- throw new IllegalThreadStateException();
- } else {
- if (this.threads == null) {
- this.threads = new Thread[4];
- } else if (this.nthreads == this.threads.length) {
- Thread[] var2 = new Thread[this.nthreads * 2];
- System.arraycopy(this.threads, 0, var2, 0, this.nthreads);
- this.threads = var2;
- }
-
- this.threads[this.nthreads] = var1;
- ++this.nthreads;
- }
- }
-
- synchronized void remove(Thread var1) {
- if (!this.destroyed) {
- for(int var2 = 0; var2 < this.nthreads; ++var2) {
- if (this.threads[var2] == var1) {
- System.arraycopy(this.threads, var2 + 1, this.threads, var2, --this.nthreads - var2);
- this.threads[this.nthreads] = null;
- break;
- }
- }
-
- if (this.nthreads == 0) {
- this.notifyAll();
- }
-
- if (this.daemon && this.nthreads == 0 && this.ngroups == 0) {
- this.destroy();
- }
-
- }
- }
-
- public synchronized void list() {
- this.list(System.out, 0);
- }
-
- void list(PrintStream var1, int var2) {
- for(int var3 = 0; var3 < var2; ++var3) {
- var1.print(" ");
- }
-
- var1.println(this);
- var2 += 4;
-
- for(int var4 = 0; var4 < this.nthreads; ++var4) {
- for(int var5 = 0; var5 < var2; ++var5) {
- var1.print(" ");
- }
-
- var1.println(this.threads[var4]);
- }
-
- for(int var7 = 0; var7 < this.ngroups; ++var7) {
- this.groups[var7].list(var1, var2);
- }
-
- }
-
- public void uncaughtException(Thread var1, Throwable var2) {
- if (this.parent != null) {
- this.parent.uncaughtException(var1, var2);
- } else {
- if (!(var2 instanceof ThreadDeath)) {
- var2.printStackTrace(System.err);
- }
-
- }
- }
-
- public String toString() {
- return this.getClass().getName() + "[name=" + this.name + ",maxpri=" + this.maxPriority + "]";
- }
- }
-